package com.cgx.entity.message;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.Date;

/**
 * @author chenguanxin
 * @date 2021-06-27 23:23
 */
@Data
@Document(collection = "session_user")
public class SessionUser {
    @Id
    @Field("id")
    private String id;
    @Field("session_id")
    private String sessionId;
    @Field("user_id")
    private String userId;
    @Field("last_read_time")
    private Date lastReadTime;
    @Field("create_by")
    private String createBy;
    @Field("create_time")
    private Date createTime;
    @Field("update_by")
    private String updateBy;
    @Field("update_time")
    private Date updateTime;
    @Field("is_delete")
    private Integer isDelete;

    public static SessionUser getSessionUser(String sessionId, String userId) {
        SessionUser sessionUser = new SessionUser();
        sessionUser.setSessionId(sessionId);
        sessionUser.setUserId(userId);
        sessionUser.setLastReadTime(new Date());
        sessionUser.setCreateBy(userId);
        sessionUser.setCreateTime(new Date());
        sessionUser.setUpdateBy(userId);
        sessionUser.setUpdateTime(new Date());
        sessionUser.setIsDelete(0);
        return sessionUser;
    }
}
